﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>外贸产品管理系统-安装</title>
<style type="text/css">
<!--
html,body{margin:0px; padding:0px; margin-left:auto; margin-right:auto; text-align:center; font-size:12px; font-family:"微软雅黑";}
body{background-color:#EAEAEA;color:#F0F0F0;}
a {color: #ffffff;text-decoration:none;}
a:hover {color: #98be01;text-decoration: none;}
.wenzi {color:#333333;}
-->
</style>
</head>

<body>
<div align="center"> 
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p style="color:#009900; font-size:22px;">一米产品跟卖系统-安装</p>
    <table width="500" border="0" cellpadding="5" cellspacing="1" bgcolor="#C9C9C9" class="wenzi">
	<form id="form1" name="form1" method="post" action="install.php">
      <tr>
        <td bgcolor="#FFFFFF"><div align="right">网站名称：</div></td>
        <td bgcolor="#FFFFFF"><div align="left">
          <input name="sitename" type="text" id="sitename" size="30" />
        </div></td>
      </tr>
      <tr>
        <td width="167" bgcolor="#FFFFFF"><div align="right">Mysql数据库服务器：</div></td>
        <td width="310" bgcolor="#FFFFFF"><div align="left">
          <input name="hostname" type="text" id="hostname" size="30" />
        </div></td>
      </tr>
      <tr>
        <td bgcolor="#FFFFFF"><div align="right">Mysql数据库用户名：</div></td>
        <td bgcolor="#FFFFFF"><div align="left">
          <input name="username" type="text" id="username" size="30" />
        </div></td>
      </tr>
      <tr>
        <td bgcolor="#FFFFFF"><div align="right">Mysql数据库密码：</div></td>
        <td bgcolor="#FFFFFF"><div align="left">
          <input name="psw" type="text" id="psw" size="30" />
        </div></td>
      </tr>
      <tr>
        <td bgcolor="#FFFFFF"><div align="right">Mysql数据库名：</div></td>
        <td bgcolor="#FFFFFF"><div align="left">
          <input name="dbname" type="text" id="dbname" size="30" />
        </div></td>
      </tr>
      <tr>
        <td bgcolor="#FFFFFF"><div align="right">后台管理员用户名：</div></td>
        <td bgcolor="#FFFFFF"><div align="left">
          <input name="admin" type="text" id="admin" size="30" />
        </div></td>
      </tr>
      <tr>
        <td bgcolor="#FFFFFF"><div align="right">后台管理员密码：</div></td>
        <td bgcolor="#FFFFFF"><div align="left">
          <input name="adminpass" type="text" id="adminpass" size="30" />
        </div></td>
      </tr>
      <tr>
        <td height="40" colspan="2" bgcolor="#FFFFFF"><div align="center">
          <input type="submit" name="Submit" value="开始安装" />
        </div>
        <div align="left"></div></td>
      </tr></form>
    </table>
<?php
function check($str){
return str_replace("'","''",$str);
}
$hostname=check(addslashes(sprintf("%s",$_POST["hostname"])));
$username=check(addslashes(sprintf("%s",$_POST["username"])));
$psw=check(addslashes(sprintf("%s",$_POST["psw"])));
$dbname=check(addslashes(sprintf("%s",$_POST["dbname"])));
$sitename=check(addslashes(sprintf("%s",$_POST["sitename"])));
$admin=check(addslashes(sprintf("%s",$_POST["admin"])));
$adminpass=check(addslashes(sprintf("%s",$_POST["adminpass"])));
echo $hostname;
echo $username;
echo $psw;
echo $dbname;
echo $admin;
echo $adminpass;
if(empty($hostname)||empty($username)||empty($psw)||empty($admin)||empty($adminpass)){
echo "请填写完整再提交";
}else{

$conn = mysqli_connect($hostname,$username,$psw,$dbname)or die(mysql_error());
echo "ok";
$word="<?php\r\n\$cfg_dbhost='".$hostname."';\r\n\$cfg_dbuser='".$username."';\r\n\$cfg_dbpwd='".$psw."';\r\n\$cfg_dbname='".$dbname."';\r\n\$site_name='".$sitename."'?>";
$fh=fopen("config.php", "w");
fwrite($fh, $word);
fclose($fh);
//创建管理员表
$sql = "CREATE TABLE ph_admin(ID int NOT NULL AUTO_INCREMENT,PRIMARY KEY(ID),admin varchar(500),adminpass varchar(500),thetype varchar(500),status varchar(500),parent varchar(500),maxhostsize int,currenthostsize int)";
mysqli_query($conn,$sql);
$sql = "INSERT INTO ph_admin(admin,adminpass,thetype)VALUES('".$admin."','".$adminpass."','超级管理员')";
mysqli_query($conn,$sql);
//创建大类表
$sql = "CREATE TABLE ph_bcategory(ID int NOT NULL AUTO_INCREMENT,PRIMARY KEY(ID),bname varchar(500),user_name varchar(500),platform varchar(500))";
mysqli_query($conn,$sql);
//创建通知表
$sql = "CREATE TABLE ph_notice(ID int NOT NULL AUTO_INCREMENT,PRIMARY KEY(ID),title varchar(500),content text,ntype varchar(500),cdate varchar(500))";
mysqli_query($conn,$sql);
//创建产品表
$sql = "CREATE TABLE ph_products(ID int NOT NULL AUTO_INCREMENT,PRIMARY KEY(ID),proname varchar(500),price float,saleprice float,coin varchar(500),code varchar(500),content text,ndate varchar(500),skucode varchar(500),user_name varchar(500),bname varchar(500),lang varchar(500),weight varchar(500),keywords text,des text,kucun int,btname varchar(500),fromurl varchar(500),platform varchar(500),shopname varchar(500),sketch text,isedit varchar(500),sid varchar(500))";
mysqli_query($conn,$sql);
//创建变体属性表
$sql = "CREATE TABLE ph_shuxing(ID int NOT NULL AUTO_INCREMENT,PRIMARY KEY(ID),cname varchar(500),proid int,price float,saleprice float,kucun int,skucode varchar(500),sid varchar(500))";
mysqli_query($conn,$sql);
//创建upc表
$sql = "CREATE TABLE ph_upc(ID int NOT NULL AUTO_INCREMENT,PRIMARY KEY(ID),upccode varchar(500),ndate varchar(500),user_name varchar(500))";
mysqli_query($conn,$sql);
//创建图片表
$sql = "CREATE TABLE ph_img(ID int NOT NULL AUTO_INCREMENT,PRIMARY KEY(ID),imgpath varchar(500),px int)";
mysqli_query($conn,$sql);
//创建图片关系表
$sql = "CREATE TABLE ph_proimg(ID int NOT NULL AUTO_INCREMENT,PRIMARY KEY(ID),imgid int,proid int,btid int,px int)";
mysqli_query($conn,$sql);
//创建登录记录
$sql = "CREATE TABLE ph_login(ID int NOT NULL AUTO_INCREMENT,PRIMARY KEY(ID),ip varchar(500),user_name varchar(500),cdate varchar(500))";
mysqli_query($conn,$sql);
//创建语言表
$sql = "CREATE TABLE ph_lang(ID int NOT NULL AUTO_INCREMENT,PRIMARY KEY(ID),lang varchar(500),lanid varchar(500));";
mysqli_query($conn,$sql);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('英语','en');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('德语','de');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('法语','fr');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('意大利语','it');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('西班牙语','es');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('日语','ja');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('泰语','th');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('丹麦语','da');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('吉尔吉斯语','ky');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('泰米尔语','ta');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('荷兰语','nl');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('波斯语','fa');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('葡萄牙语','pt');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('罗马尼亚语','ro');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('波兰语','pl');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('匈牙利语','hu');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('挪威语','no');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('冰岛语','is');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('尼泊尔语','ne');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('立陶宛语','lt');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('保加利亚语','bg');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('老挝语','lo');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('白俄罗斯语','be');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('希腊语','el');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('越南语','vi');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('希伯来语','iw');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('拉丁语','la');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('缅甸语','my');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('爱尔兰语','ga');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('芬兰语','fi');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('乌克兰语','uk');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('蒙古语','mn');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('菲律宾语','tl');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('印尼语','id');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('阿拉伯语','ar');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('俄语','ru');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('印地语','hi');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('土耳其语','tr');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('瑞典语','sv');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('马来语','ms');";
mysqli_query($conn,$sqls);
$sqls= "INSERT INTO ph_lang(lang,lanid)VALUES('加泰罗尼亚语','ca');";
mysqli_query($conn,$sqls);

mysqli_close($conn);
echo "<script language=JavaScript>\r\n";
echo "alert('安装成功!');\r\n";
echo "location.href='index.php'\r\n";
echo "</script>";
	}
	?>
</div>
</body>
</html>
